﻿using SD.DALFactory;
using SD.DataAccess.Repository;
using SD.Entity;
using SD.Entity.PageSearch;
using SD.Entity.SearchEntity;
using SD.Interface.Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SD.Business.Service
{
    public class RoleInfoService : IRoleInfoService
    {
        private RoleInfoRepository roleInfoRepository;
        public RoleInfoService()
        {
            roleInfoRepository = AbstractFactory.CreateRoleInfoRepository();
        }

        public RoleInfo GetRoleInfo(int id)
        {
            return roleInfoRepository.GetRoleInfo(id);
        }

        public int DeleteRoleInfo(int id)
        {
            return roleInfoRepository.DeleteRoleInfo(id);
        }

        public int SaveRoleInfo(RoleInfo roleInfo)
        {
            if (roleInfo.Id <= 0)
            {
                return (int)roleInfoRepository.Insert(roleInfo);
            }
            else
            {
                return (int)roleInfoRepository.Update(roleInfo);
            }
        }

        public List<RoleInfo> GetRoleInfoList(RoleInfoSearch search)
        {
            return roleInfoRepository.GetRoleInfoList(search);
        }

        public PagedList<RoleInfo> QueryRoleInfoList(RoleInfoSearch search, PageView view)
        {
            return roleInfoRepository.QueryRoleInfoList(search, view);
        }
    }
}
